import { createBrowserRouter, Navigate } from 'react-router-dom';
import AppLayout from './components/Layout/AppLayout';
import Dashboard from './pages/Dashboard/Dashboard';
import ConnectionList from './pages/Connections/ConnectionList';
import ConnectionCreate from './pages/Connections/ConnectionCreate';
import DomainList from './pages/Domains/DomainList';
import DomainDetail from './pages/Domains/DomainDetail';
import DomainCreate from './pages/Domains/DomainCreate';
import DomainConsole from './pages/Domains/DomainConsole';
import StoragePoolList from './pages/Storage/StoragePoolList';
import VolumeList from './pages/Storage/VolumeList';
import VolumeCreate from './pages/Storage/VolumeCreate';
import NetworkList from './pages/Networks/NetworkList';
import NetworkCreate from './pages/Networks/NetworkCreate';
import SystemInfo from './pages/System/SystemInfo';

export const router = createBrowserRouter([
  {
    path: '/',
    element: <AppLayout />,
    children: [
      {
        index: true,
        element: <Navigate to="/dashboard" replace />,
      },
      {
        path: 'dashboard',
        element: <Dashboard />,
      },
      {
        path: 'connections',
        children: [
          {
            index: true,
            element: <ConnectionList />,
          },
          {
            path: 'create',
            element: <ConnectionCreate />,
          },
        ],
      },
      {
        path: 'domains',
        children: [
          {
            index: true,
            element: <DomainList />,
          },
          {
            path: 'create',
            element: <DomainCreate />,
          },
          {
            path: ':name',
            element: <DomainDetail />,
          },
          {
            path: ':name/console',
            element: <DomainConsole />,
          },
        ],
      },
      {
        path: 'storage',
        children: [
          {
            index: true,
            element: <StoragePoolList />,
          },
          {
            path: 'pools',
            element: <StoragePoolList />,
          },
          {
            path: 'volumes',
            element: <VolumeList />,
          },
          {
            path: 'volumes/create',
            element: <VolumeCreate />,
          },
        ],
      },
      {
        path: 'networks',
        children: [
          {
            index: true,
            element: <NetworkList />,
          },
          {
            path: 'create',
            element: <NetworkCreate />,
          },
        ],
      },
      {
        path: 'system',
        element: <SystemInfo />,
      },
    ],
  },
]);

export default router;